define(['app', 'assets/js/bootstrap.bundle.min.js', 'assets/js/bootstrap-select.js'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {

	$scope.form = {};

	$scope.save = function() {
		if (!$scope.formCheck()){
			return;
		}
		let ids="";
		let arrayIds = $('#my_select').val();
		arrayIds.forEach((item,index,arr)=> {
			ids = ids+",'"+item+"'";
		})
		let fk_teachers = ids.replace(',','');
		$scope.form.fk_teachers = fk_teachers;
		httpService.post(app.urls.saveLeaveOfficeUser, $scope.form, function (data) {
			if (data.code == "0000") {
				eventBusService.publish("content.page.reload", data);
				eventBusService.publish("modal.page.close", {});
			} else {
				eventBusService.publish("modal.alert", {"content": data.msg});
			}
		});
	}

	//性别
	$scope.getTeacherList = function (){
		httpService.post(app.urls.getTeacher,{},function(data){
			if("0000" === data.code){
				$scope.teacherList = data.data;
			}else{
				alert(data.msg);
			}
		});
	}

	let init = function () {
		$scope.getTeacherList();
		setTimeout(function (){
			$('#my_select').selectpicker({
				'noneSelectedText': '==请选择==',
				'hideDisabled': true,
				'liveSearch': true,
				'noneResultsText': '没有匹配到查询结果：{0}',
				'header': '选择教职工',
				'size': 10,
				'maxOptions': 5,
				'maxOptionsText': '最多只能选择5个人'
			});
		}, 100);
	}

	init();

}}});